DEPTH_LAYERS = 50#resnet50
POSE_LAYERS = 18#resnet18
FRAME_IDS = [0, -1, 1, 's']#0 refers to current frame, -1 and 1 refer to temperally adjacent frames, 's' refers to stereo adjacent frame.
IMGS_PER_GPU = 2 #the number of images fed to each GPU
HEIGHT = 192#input image height
WIDTH = 640#input image width


data = dict(
    name = 'kitti_odom',#dataset name   # 数据集格式 kitti/kitti_odom
    split = 'odom',#training split name  # 文件路径 odom exp eigen_full
    height = HEIGHT,
    width = WIDTH,
    frame_ids = FRAME_IDS,
    in_path = r'/home/lin/code/graduation_project/AD-Depth-Estimation/FeatDepth/datasets/kitti_odom',#path to raw data
    gt_depth_path = './splits/eigen/gt_depths.npz',#path to gt data
    png = True,#image format
    stereo_scale = True if 's' in FRAME_IDS else False,
)

model = dict(
    name = 'mono_fm',# select a model by name
    depth_num_layers = DEPTH_LAYERS,
    pose_num_layers = POSE_LAYERS,
    frame_ids = FRAME_IDS,
    imgs_per_gpu = IMGS_PER_GPU,
    height = HEIGHT,
    width = WIDTH,
    scales = [0, 1, 2, 3],# output different scales of depth maps
    min_depth = 0.1, # minimum of predicted depth value
    max_depth = 100.0, # maximum of predicted depth value
    # 深度估计网络的预训练路径
    depth_pretrained_path = './weights/resnet{}.pth'.format(DEPTH_LAYERS),# pretrained weights for resnet
    # pose估计预训练权重
    pose_pretrained_path =  './weights/resnet{}.pth'.format(POSE_LAYERS),# pretrained weights for resnet
    #一阶段提特征权重
    extractor_pretrained_path = '/home/lin/code/graduation_project/AD-Depth-Estimation/FeatDepth/weights/autoencoder.pth',# pretrained weights for autoencoder
    # extractor_pretrained_path = '/home/lin/code/graduation_project/AD-Depth-Estimation/FeatDepth/log/kitti_autoencoder/latest.pth',# pretrained weights for autoencoder
    automask = False if 's' in FRAME_IDS else True,   # 自动编码。如果是s就不掩码
    disp_norm = False if 's' in FRAME_IDS else True,
    perception_weight = 1e-3,   # 权重
    smoothness_weight = 1e-3,  # 平滑损失权重
)

# resume_from = '/node01_data5/monodepth2-test/model/ms/ms.pth'#directly start training from provide weights
resume_from = None  # 在训练
finetune = None     # 在线训练
# finetune = './weights/fm_depth_odom.pth'    pose
total_epochs = 1      # 周期
imgs_per_gpu = IMGS_PER_GPU
learning_rate = 1e-4    # 学习率
workers_per_gpu = 2
validate = False       # 是否验证。odom时不用


# 优化器相关设置，可以默认
optimizer = dict(type='Adam', lr=learning_rate, weight_decay=0)
optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2))
lr_config = dict(
    policy='step',
    warmup='linear',
    warmup_iters=500,
    warmup_ratio=1.0 / 3,
    step=[20,30],
    gamma=0.5,
)

checkpoint_config = dict(interval=1)
log_config = dict(interval=1,    # 迭代50次，就打印一次结果
                  hooks=[dict(type='TextLoggerHook'),])
dist_params = dict(backend='nccl')
log_level = 'INFO'
load_from = None
workflow = [('train', 1)]
